import { Modal } from '@bytedance/mona-ui';
import Agreement from './Agreement'
export const Agreement = () => {
    return new Promise((resolveW, rejectW) => {
        // 还需要从缓存中获取
        let conterAllConter = localStorage.getItem('dlyAgreement')
        if (conterAllConter == '1') {
            resolveW()
            return
        }
        Modal.confirm({
            title: '抖羚羊许可及服务协议',
            content: Agreement(),
            okText: '同意',
            width: 800,
            style: {
                height: '800px',
                maxHeight: '800px'
            },
            // centered: true,
            // maskClosable: false,
            closable: false,
            cancelText: '不同意',
            onOk: () => {
                console.log('已经同意 通知全局')
                resolveW()
                localStorage.setItem('dlyAgreement', '1')
            },
            onCancel: () => {
                localStorage.setItem('dlyAgreement', '0')
                return new Promise((resolve, reject) => {
                    Modal.warning({
                        title: '提示',
                        content: '您若拒绝许可及服务协议，无法使用抖羚羊全部功能',
                        okText: '确定拒绝服务',
                        onCancel: () => {
                            reject()

                        },
                        onOk: () => {
                            resolve(true)
                            Modal.warning({
                                title: '提示',
                                content: '抱歉，我们暂时无权为您提供服务，请您自行手动卸载插件。如有疑问，请联系我们。',
                                showCancel: false,
                                onOk: () => {
                                    rejectW()
                                }
                            })
                        }
                    })
                })
            }
        })

    })
}